<%
'***************************************************
'赤金CMS www.cjAsp.com All Rights Reserved 
'文件名称：app.inc
'作用：网站主要方法
'***************************************************
dim app
set app = new appModel

'防止存在命名空间的问题，定义为class
class appModel
    private errorTotal '错误日志错误数
	'***************************************************
	'初始值
	'***************************************************
	'public sub class_initialize()
	public sub webInit()
		siteName = getConfig("siteName")
		if siteName = "" then
			updateCache "config"
		end if
		siteUrl = getSiteUrl()
		cookieTime = getConfig("cookieTime")
		cacheExpireTime = getConfig("cacheExpireTime")
		newPic = int(getConfig("newPic"))

		siteName = getConfig("siteName")
		siteTitle = getConfig("siteTitle")
		isHtml = cj_bool(getConfig("isHtml"))
		isBook = cj_bool(getConfig("isBook"))
		fileExt = getConfig("fileExt")
		checkAmount = getConfig("checkAmount")
		bookAuditing = getConfig("bookAuditing")
		uploadDir = getConfig("uploadDir")
		indexViewID  = getConfig("indexViewID")
		ourViewID  = getConfig("ourViewID")
		
		uploadType  = getConfig("uploadType")
		uploadSize  = getConfig("uploadSize")
		
		newsRows  = getConfig("newsRows")
		productRows  = getConfig("productRows")
		bookRows  = getConfig("bookRows")
	end sub

	'***************************************************
	'函数名：getSiteUrl 取得网站链接
	'***************************************************
	public function getSiteUrl()
		dim url : url = "http://" & request.serverVariables("SERVER_NAME") & request.serverVariables("SCRIPT_NAME")
		getSiteUrl = left(url, inStrRev(url, "/"))
	end function

	'***************************************************
	'函数名：newsList 显示文章列表
	'1 -- iCid 栏目ID数组,0为所有栏目
	'2 -- iNum 文章数
	'3 -- isList 是否显示所属栏目名称，1为显示，否则不显示
	'4 -- ByType 排序方式 1 id倒序,2 id升序,3 按时间倒序,4 按时间升序,5 按点击倒序,6 按点击升序,7 随机
	'5 -- lType 显示方式 1 换行样式，2 DIV 样式，否则 li样式
	'6 -- tLen 标题字符数，大于0 则显示指定字符
	'7 -- ConLen 内容字符数，大于0 则显示指定字符
	'8 -- iDate 显示日期的样式，0 不显示，1 显示"年月日"，2 显示"(年)-(月)-(日)"，3 显示"月-日"
	'9 -- oType 文章打开方式，1 新窗口打开，否则原窗口打开
	'10 -- Css1 奇数行的CSS样式名
	'11 -- Css2 偶数行的CSS样式名
	'***************************************************
	public function newsList(iCid, iNum, isList, ByType, lType, tLen, ConLen, iDate, oType, Css1, Css2)
		dim str, rs, sql, data, tCc
		str = ""
		tCc = reChar(iCid) & iNum & isList & iNum & isList & ByType & lType & tLen & ConLen & iDate & oType & reChar(Css1) & reChar(Css2)
		tCc = "newsList-" & toEnglish(tCc)
		if fileCacheExpire(tCc) then
		'if appCacheCheck(tCc) then
			iCid = reClass(iCid)
			iNum = int(iNum)
			ByType = int(ByType)
			sql = "select"
			if iNum > 60 then iNum = 60
			if iNum > 0 then sql = sql & " top " & iNum
			sql = sql & " id,classID,title,dateTime,content from cj_news where auditing=true "
			if iCid > 0 then sql = sql & " and classID=" & iCid
			sql = sql & " Order By isTop asc,"
			select case ByType
				case 1, 2
				case 3		: sql = sql & "dateTime desc,"
				case 4		: sql = sql & "dateTime asc,"
				case 5		: sql = sql & "hits desc,"
				case 6		: sql = sql & "hits asc,"
				case 7		: sql = sql & "Rnd(Rnd(id*(-timer())*1000)*now()),"
				case else	: sql = sql & "id desc,"
			end select
			if ByType = 2 then sql = sql & "id asc" else sql = sql & "id desc"
			data = db.GetData(sql)
			if isArray(data) then
				dim i, tOpen, iCss, cInfo, sTitle, aTitle, sCon, sDate, sCss, sUrl
				iCss = Css1
				isList = int(isList)
				tLen = int(tLen)
				ConLen = int(ConLen)
				iDate = int(iDate)
				oType = int(oType)
				for i = 0 to ubound(data, 2)
					sDate = "" : tOpen = "" : sCon = "" : sCss = ""
					cInfo = getClassInfo(data(1,i))
					sTitle = data(2,i)
					aTitle = sTitle
					if tLen > 0 then sTitle = getLength(sTitle, tLen)
					if ConLen > 0 then sCon = "<div class=""art_content"">" & getStrContent(data(4,i), ConLen) & "</div>"
					sDate = dateType(iDate, data(3,i))
					if oType = 1 then tOpen = " target=""_blank"""
					if isList = 1 then sCss = "<a href=""" & getTypeUrl("l", data(1,i)) & """" & tOpen & ">" & cInfo(2) & " </a>"
					sUrl = "<a title=""" & aTitle & """ href=""" & getInfoUrl(3,data(0,i),1) & """" & tOpen & ">" & sTitle & "</a>" & getNewPic(data(3,i))
					select case int(lType)
						case 1 : str = str & sUrl & sCon & sDate & "<br>"' 换行输出
						case 2
							str = str & "<div"
							if iCss <> "" then str = str & " class=""" & iCss & """"
							str = str & ">" & sDate & sCss & sUrl & sCon & "</div>" ' DIV输出
						case else
							str = str & "<li"
							if iCss <> "" then str = str & " class=""" & iCss & """"
							str = str & ">" & sDate & sCss & sUrl & sCon & "</li>" ' li输出
					end select
					if (i + 1) mod 2 = 0 then iCss = Css1 else iCss = Css2
				next
			else
				str = "<li>没有文章！</li>"
			end if
			'setAppCache tCc, str '生成
			fileCacheWrite tCc, str '写入文件缓存
		else
			'str = getAppCache(tCc) '读取
			str = fileCacheLoad(tCc) '读取缓存
		end if
		newsList = str
	end function

	'***************************************************
	'函数名：productList 显示产品列表
	'1 -- iCid 栏目ID数组,0为所有栏目
	'2 -- iNum 产品数
	'3 -- isList 是否显示所属栏目名称，1为显示，否则不显示
	'4 -- isPrice 是否显示产品价格，1 显示，否则不显示
	'5 -- ByType 排序方式 1 id倒序,2 id升序,3 按生产日期倒序,4 按生产日期升序,5 按点击倒序,6 按点击升序,7 随机
	'6 -- lType 显示方式 1 换行样式，2 DIV 样式，否则 li样式
	'7 -- tLen 标题字符数，大于0 则显示指定字符
	'8 -- ConLen 内容字符数，大于0 则显示指定字符
	'9 -- iDate 显示生产日期的样式，0 不显示，1 显示"年月日"，2 显示"(年)-(月)-(日)"，3 显示"月-日"
	'10 -- oType 产品列表打开方式，1 新窗口打开，否则原窗口打开
	'11 -- Css1 奇数行的CSS样式名
	'12 -- Css2 偶数行的CSS样式名
	'***************************************************
	public function productList(iCid, iNum, isList, isPrice, ByType, lType, tLen, ConLen, iDate, oType, Css1, Css2)
		dim str, rs, sql, data, tCc
		str = ""
		tCc = reChar(iCid) & iNum & isList & isPrice & ByType & lType & tLen & ConLen & iDate & oType & reChar(Css1) & reChar(Css2)
		tCc = "productList-" & toEnglish(tCc)
		if fileCacheExpire(tCc) then
		'if appCacheCheck(tCc) then
			iCid = int(reClass(iCid))
			iNum = int(iNum)
			ByType = int(ByType)
			sql = "select"
			if iNum > 60 then iNum = 60
			if iNum > 0 then sql = sql & " top " & iNum
			sql = sql & " id,classID,title,dateTime,content,price from cj_product where isStop=false "
			if iCid > 0 then sql = sql & " and classID=" & iCid
			sql = sql & " Order By "
			select case ByType
				case 1, 2
				case 3		: sql = sql & "dateTime desc,"
				case 4		: sql = sql & "dateTime asc,"
				case 5		: sql = sql & "hits desc,"
				case 6		: sql = sql & "hits asc,"
				case 7		: sql = sql & "Rnd(Rnd(id*(-timer())*1000)*now()),"
				case else	: sql = sql & "id desc,"
			end select
			if ByType = 2 then sql = sql & "id asc" else sql = sql & "id desc"
			data = db.GetData(sql)
			if isArray(data) then
				dim i, tOpen, tprice, iCss, cInfo, sTitle, aTitle, sCon, sDate, sCss, sUrl
				iCss = Css1
				tLen = int(tLen)
				ConLen = int(ConLen)
				iDate = int(iDate)
				isList = int(isList)
				oType = int(oType)
				for i = 0 to ubound(data, 2)
					sDate = "" : tOpen = "" : tprice = "" : sCon = "" : sCss = ""
					cInfo = getClassInfo(data(1,i))
					sTitle = data(2,i)
					aTitle = sTitle
					if tLen > 0 then sTitle = getLength(sTitle, tLen)
					if ConLen > 0 then sCon = "<div class=""pro_content"">" & getStrContent(data(4,i), ConLen) & "</div>"
					sDate = dateType(iDate, data(3,i))
					if oType = 1 then tOpen = " target=""_blank"""
					if isList = 1 then sCss = "<a href=""" & getTypeUrl("l", data(1,i)) & """" & tOpen & ">" & cInfo(2) & " </a>"
					if isPrice = 1 and int(data(5,i)) > 0 then tprice = "<span class='price'>" & formatCurrency(data(5,i),2) & "元</span>"
					sUrl = "<a title=""" & aTitle & """ href=""" & getInfoUrl(1,data(0,i),1) & """" & tOpen & ">" & sTitle & "</a>"
					select case int(lType)
						case 1 : str = str & sUrl & tprice & sCon & sDate & "<br>"' 换行输出
						case 2
							str = str & "<div"
							if iCss <> "" then str = str & " class=""" & iCss & """"
							str = str & ">" & sDate & sCss & sUrl & tprice & sCon & "</div>"' DIV输出
						case else
							str = str & "<li"
							if iCss <> "" then str = str & " class=""" & iCss & """"
							str = str & ">" & sDate & sCss & sUrl & tprice & sCon & "</li>" ' li输出
					end select
					if (i + 1) mod 2 = 0 then iCss = Css1 else iCss = Css2
				next
			else
				str = "<li>没有产品！</li>"
			end if
			'setAppCache tCc, str '生成
			fileCacheWrite tCc, str '写入文件缓存
		else
			'str = getAppCache(tCc) '读取
			str = fileCacheLoad(tCc) '读取缓存
		end if
		productList = str
	end function

	'***************************************************
	'函数名：bookList 显示留言列表
	'1 -- iCid 栏目ID数组,0为所有栏目
	'2 -- iNum 留言数
	'3 -- isList 是否显示所属栏目名称，1为显示，否则不显示
	'4 -- lType 显示方式 1 换行样式，2 DIV 样式，否则 li样式
	'5 -- tLen 标题字符数，大于0 则显示指定字符
	'6 -- ConLen 内容字符数，大于0 则显示指定字符
	'7 -- oType 留言列表打开方式，1 新窗口打开，否则原窗口打开
	'8 -- Css1 奇数行的CSS样式名
	'9 -- Css2 偶数行的CSS样式名
	'***************************************************
	public function bookList(iCid, iNum, isList, lType, tLen, ConLen, oType, Css1, Css2)
		dim str, rs, sql, i, data
		str = ""
		iCid = int(reClass(iCid))
		iNum = int(iNum)
		sql = "select"
		if iNum > 60 then iNum = 60
		if iNum > 0 then sql = sql & " top " & iNum
		sql = sql & " id,classID,title,content,isShow from cj_book where auditing=true and replyID=0"
		if iCid > 0 then sql = sql & " and classID=" & iCid
		sql = sql & " Order By id desc"
		data = db.GetData(sql)
		if isArray(data) then
			dim cInfo, sTitle, aTitle, sCon, iCon, sCss, sUrl, tOpen, iCss
			tLen = int(tLen)
			ConLen = int(ConLen)
			isList = int(isList)
			oType = int(oType)
			iCss = Css1
			for i = 0 to ubound(data, 2)
				tOpen = "" : sCon = "" : sCss = ""
				cInfo = getClassInfo(data(1,i))
				sTitle = data(2,i)
				aTitle = sTitle
				if cj_bool(data(4,i)) then iCon = data(3,i) else iCon = "非公开留言"
				if tLen > 0 then sTitle = getLength(sTitle, tLen)
				if ConLen > 0 then sCon = "<div class=""book_content"">" & getStrContent(iCon, ConLen) & "</div>"
				if oType = 1 then tOpen = " target=""_blank"""
				if isList = 1 then sCss = "<a href=""" & getTypeUrl("l", data(1,i)) & """" & tOpen & ">" & cInfo(2) & " </a>"
				sUrl = "<a title=""" & aTitle & """ href=""" & getInfoUrl(2,data(0,i),1) & """" & tOpen & ">" & sTitle & "</a>"
				select case int(lType)
					case 1 : str = str & sUrl & sCon & "<br>" ' 换行输出
					case 2
						str = str & "<div"
						if iCss <> "" then str = str & " class=""" & iCss & """"
						str = str & ">" & sCss & sUrl & sCon & "</div>" ' DIV输出
					case else
						str = str & "<li"
						if iCss <> "" then str = str & " class=""" & iCss & """"
						str = str & ">" & sCss & sUrl & sCon & "</li>" ' li输出
				end select
				if (i + 1) mod 2 = 0 then iCss = Css1 else iCss = Css2
			next
		else
			str = "<li>没有留言！</li>"
		end if
		bookList = str
	end function

	'***************************************************
	'函数名：ourList 显示公司简介列表
	'1 -- iNum 简介条数
	'2 -- tLen 标题字符数，大于0 则显示指定字符
	'3 -- Css1 奇数行的CSS样式名
	'4 -- Css2 偶数行的CSS样式名
	'***************************************************
	public function ourList(iNum, tLen, Css1, Css2)
		dim tCc, str
		str = ""
		tCc = iNum & tLen & reChar(Css1) & reChar(Css2)
		tCc = "ourList-" & toEnglish(tCc)
		if fileCacheExpire(tCc) then
		'if appCacheCheck(tCc) then
			dim rs, sql, i, data, sTitle, aTitle, iCss
			iNum = int(iNum)
			sql = "select"
			if iNum > 20 then iNum = 20
			if iNum > 0 then sql = sql & " top " & iNum
			sql = sql & " id,title from cj_our where not isStop Order By orderID asc,id desc"
			data = db.GetData(sql)
			if isArray(data) then
				tLen = int(tLen)
				iCss = Css1
				for i = 0 to ubound(data, 2)
					sTitle = data(1,i)
					aTitle = sTitle
					if tLen > 0 then sTitle = getLength(sTitle, tLen)
					str = str & "<li"
					if iCss <> "" then str = str & " class=""" & iCss & """"
					str = str & "><a title=""" & aTitle & """ href=""" & getInfoUrl(4,data(0,i),1) & """>" & sTitle & "</a></li>"
					if (i + 1) mod 2 = 0 then iCss = Css1 else iCss = Css2
				next
			else
				str = "<li>没有公司简介！</li>"
			end if
			'setAppCache tCc, str '生成
			fileCacheWrite tCc, str '写入文件缓存
		else
			'str = getAppCache(tCc) '读取
			str = fileCacheLoad(tCc) '读取缓存
		end if
		ourList = str
	end function

	'***************************************************
	'函数名：newsCustomList 显示新闻自定义列表
	'1 -- iCid 栏目ID数组,0为所有栏目
	'2 -- iNum 条数 0为所有
	'3 -- strHtml 自定义HTML代码
	'***************************************************
	public function newsCustomList(ByVal iCid, iNum, strHtml)
		if isNull(strHtml) or trim(strHtml) = "" then
			newsCustomList = ""
			exit function
		end if
		dim rs, sql, str, i, j, ii, n, data, temp, iCon
		iCid = int(reClass(iCid))
		iNum = int(iNum)
		sql = "select"
		if iNum > 0 then sql = sql & " top " & iNum
		sql = sql & " id,classID,title,author,copyFrom,hits,dateTime,content,picUrl,genreID from cj_news where auditing=true and genreID=" & genreID
		if iCid > 0 then sql = sql & " and classID=" & iCid
		sql = sql & " Order By isTop asc, id desc"
		str = ""
		rows = newsRows
		temp = db.arrayData(sql, page, rows)
		infoTotal = temp(0)
		data = temp(1)
		if isArray(data) then
			for i = 0 to ubound(data, 2)
				str = str & strHtml
				str = reAllClass(data(1,i), str)
				iCon = data(7,i)
				str = replace(str, "{$infoID}", data(0,i))
				str = replace(str, "{$infoUrl}", getInfoUrl(3,data(0,i),1))
				str = replace(str, "{$author}", data(3,i))
				str = replace(str, "{$copyFrom}", data(4,i))
				str = replace(str, "{$title}", data(2,i))
				str = replace(str, "{$dateTime}", cj_date(data(6,i)))
				str = replace(str, "{$content}", iCon)
				str = replace(str, "{$hits}", data(5,i))
				str = replace(str, "{$picUrl}", getInfoPic(data(8,i)))
				if inStr(str, "{$conLen") > 0 then
					re.pattern = "\{\$conLen\((\d+)\)\}"
					set ii = re.execute(str)
					for each j in ii
						n = int(j.subMatches(0))
						if n > 0 then str = replace(str, j, getStrContent(iCon, n))
					next
					set ii = nothing
				end if
			next
		else
			str = "没有添加文章！"
		end if
		newsCustomList = str
	end function

	'***************************************************
	'函数名：productCustomList 显示产品自定义列表
	'1 -- iCid 栏目ID数组,0为所有栏目
	'2 -- iNum 条数 0为所有
	'3 -- strHtml 自定义HTML代码
	'***************************************************
	public function productCustomList(ByVal iCid, iNum, strHtml)
		if isNull(strHtml) or trim(strHtml) = "" then
			productCustomList = ""
			exit function
		end if
		dim rs, sql, str, i, j, ii, n, data, temp, iprice, iisStop, iCon
		iCid = int(reClass(iCid))
		iNum = int(iNum)
		sql = "select"
		if iNum > 0 then sql = sql & " top " & iNum
		sql = sql & " id,classID,title,productType,price,manufacturer,dateTime,content,hits,isStop,picUrl,proUrl1,proUrl2 from cj_product where isStop=false"
		if iCid > 0 then sql = sql & " and classID=" & iCid
		sql = sql & " Order By id desc "
		str = ""
		rows = productRows
		temp = db.arrayData(sql, page, rows)
		infoTotal = temp(0)
		data = temp(1)
		if isArray(data) then
			for i = 0 to ubound(data, 2)
				str = str & strHtml
				str = reAllClass(data(1,i), str)
				iCon = data(7,i)
				if cj_bool(data(9,i)) then iisStop = "<font color=red>停产</font>" else iisStop = "<font color='#29b629'>在产</font>"
				if int(data(4,i)) > 0 then iprice = formatCurrency(data(4,i), 2) & "元" else iprice = "电话咨询"
				str = replace(str, "{$infoID}", data(0,i))
				str = replace(str, "{$infoUrl}", getInfoUrl(1,data(0,i),1))
				str = replace(str, "{$manufacturer}", data(5,i))
				str = replace(str, "{$productType}", data(3,i))
				str = replace(str, "{$title}", data(2,i))
				str = replace(str, "{$dateTime}", FormatDateTime(cj_date(data(6,i)), 2))
				str = replace(str, "{$content}", iCon)
				str = replace(str, "{$hits}", data(8,i))
				str = replace(str, "{$picUrl}", getInfoPic(data(10,i)))
				str = replace(str, "{$price}", iprice)
				str = replace(str, "{$isTop}", iisStop)
				str = replace(str, "{$proUrl1}", data(11,i))
				str = replace(str, "{$proUrl2}", data(12,i))
				if inStr(str, "{$conLen") > 0 then
					re.pattern = "\{\$conLen\((\d+)\)\}"
					set ii = re.execute(str)
					for each j in ii
						n = int(j.subMatches(0))
						if n > 0 then str = replace(str, j, getStrContent(iCon, n))
					next
					set ii = nothing
				end if
			next
		else
			str = "没有添加产品！"
		end if
		productCustomList = str
	end function

	'***************************************************
	'函数名：bookCustomList 显示留言自定义列表
	'1 -- iCid 栏目ID数组,0为所有栏目
	'2 -- iNum 条数 0为所有
	'3 -- strHtml 自定义HTML代码
	'***************************************************
	public function bookCustomList(ByVal iCid, iNum, strHtml)
		if isNull(strHtml) or trim(strHtml) = "" then
			exit function
			bookCustomList = ""
		end if
		dim rs, sql, str, i, j, ii, n, data, temp, cInfo, iCon, iIsTop, iEMail
		iCid = int(reClass(iCid))
		iNum = int(iNum)
		sql = "select"
		if iNum > 0 then sql = sql & " top " & iNum
		sql = sql & " id,classID,userName,userIP,userAddr,title,dateTime,content,hits,isTop,isShow,userEmail "
		sql = sql & "from cj_book where auditing=true and replyID=0"
		if iCid > 0 then sql = sql & " and classID=" & iCid
		sql = sql & " Order By isTop asc, id desc "
		str = ""
		rows = bookRows
		temp = db.arrayData(sql, page, rows)
		infoTotal = temp(0)
		data = temp(1)
		if isArray(data) then
			for i = 0 to ubound(data, 2)
				str = str & strHtml
				str = reAllClass(data(1,i), str)
				if cj_bool(data(10,i)) then
					iCon = tidyContent(data(7,i))
					iEMail = data(11,i)
				else
					iCon = "非公开留言"
					iEMail = "保密"
				end if
				if cj_bool(data(9,i)) then iIsTop = "<font color=""red"">置顶</font>" else iIsTop = ""
				str = replace(str, "{$infoID}", data(0,i))
				str = replace(str, "{$userName}", "" & data(2,i))
				str = replace(str, "{$userIP}", "" & data(3,i))
				str = replace(str, "{$userAddr}", "" & data(4,i))
				str = replace(str, "{$infoUrl}", getInfoUrl(2,data(0,i),1))
				str = replace(str, "{$dateTime}", bookDate(data(6,i)))
				str = replace(str, "{$isTop}", iIsTop)
				str = replace(str, "{$hits}", data(8,i))
				str = replace(str, "{$title}", "" & data(5,i))
				str = replace(str, "{$content}", "" & iCon)
				str = replace(str, "{$userEmail}", "" & iEMail)
				if inStr(str, "{$conLen") > 0 then
					re.pattern = "\{\$conLen\((\d+)\)\}"
					set ii = re.execute(str)
					for each j in ii
						n = int(j.subMatches(0))
						if n > 0 then str = replace(str, j, getStrContent(iCon, n))
					next
					set ii = nothing
				end if
				if inStr(str, "{$reCount}") > 0 then
					str = replace(str, "{$reCount}", conn.execute("select Count(id) from cj_book where auditing=true and replyID=" & data(0,i))(0))
				end if
			next
		else
			str = "没有留言！"
		end if
		bookCustomList = str
	end function

	'***************************************************
	'函数名：reBookCustomList 显示留言自定义列表
	'strHtml 自定义HTML代码
	'***************************************************
	public function reBookCustomList(strHtml)
		if (isNull(strHtml) or trim(strHtml) = "") or infoID = 0 then
			reBookCustomList = ""
			exit function
		end if
		dim rs, sql, str, i, j, ii, n, data, temp, iCon, iIsTop, iEMail, iLouCeng, iUserName
		sql = "select id,userName,userIP,userAddr,title,dateTime,content,isTop,isShow,userEmail,ReAdmin from cj_book where auditing=true and replyID in(" & infoID & ") Order By isTop asc, id asc"
		str = ""
		rows = bookRows
		temp = db.arrayData(sql, page, rows)
		infoTotal = temp(0)
		data = temp(1)
		if isArray(data) then
			iLouCeng = db.getPagePosition(infoTotal, page, rows)
			for i = 0 to ubound(data, 2)
				str = str & strHtml
				if cj_bool(data(7,i)) then iIsTop = "<font color=""red"">置顶回复</font>" else iIsTop = ""
				iCon = data(6,i)
				if cj_bool(data(8,i)) then
					iCon = tidyContent(data(6,i))
					iEMail = data(9,i)
				else
					iCon = "非公开留言"
					iEMail = "保密"
				end if
				if int(data(10,i)) > 0 then
					iUserName = "<font color=""red"">管理员</font>"
				else
					iUserName = "" & contentTag(data(1,i),0)
				end if
				str = replace(str, "{$replyID}", data(0,i))
				str = replace(str, "{$reUserName}", iUserName)
				str = replace(str, "{$reUserIP}", "" & data(2,i))
				str = replace(str, "{$reUserAddr}", "" & data(3,i))
				str = replace(str, "{$reTitle}", "" & data(4,i))
				str = replace(str, "{$reDateTime}", bookDate(data(5,i)))
				str = replace(str, "{$reContent}", "" & iCon)
				str = replace(str, "{$reIsTop}", iIsTop)
				str = replace(str, "{$reEmail}", "" & iEMail)
				str = replace(str, "{$louCeng}", iLouCeng & "楼")
				if inStr(str, "{$conLen") > 0 then
					re.pattern = "\{\$conLen\((\d+)\)\}"
					set ii = re.execute(str)
					for each j in ii
						n = int(j.subMatches(0))
						if n > 0 then str = replace(str, j, getStrContent(iCon, n))
					next
					set ii = nothing
				end if
				iLouCeng = iLouCeng + 1
			next
		end if
		reBookCustomList = str
	end function

	public function getNews(ByVal iid)
		dim str : str = ""
		if iid > 0 then
			dim sql, data, pn
			sql = "select classID,title,author,copyFrom,dateTime,isTop,content,infoViewID,hits,picUrl,auditing from cj_news where id=" & iid
			data = db.GetData(sql)
			if not isArray(data) then message "id不存在！"
			if not data(10,0) then message "id已经禁用！"
			classID = data(0,0)
			call setClass(classID)
			call setGenre(genreID)
			infoID = iid
			genreType = 3
			title = contentTag(data(1,0),0)
			author = data(2,0)
			copyFrom = data(3,0)
			dateTime = cj_date(data(4,0))
			isTop = data(5,0)
			content = tidyContent(data(6,0))
			infoViewID = data(7,0)
			hits = data(8,0)
			if page = 1 then hits = hits & hitsJs(iid)
			picUrl = getInfoPic(data(9,0))
			if infoViewID > 0 then viewID = infoViewID else viewID = contentViewID
			infoUrl = getInfoUrl(genreType,iid,1)
			pn = getPrevNext(iid)
			prevInfo = pn(0)
			nextInfo = pn(1)
		end if
		getNews = str
	end function

	public function getProduct(ByVal iid)
		dim str : str = ""
		if iid > 0 then
			dim sql, data, pn
			sql = "select classID,title,price,manufacturer,productType,dateTime,content,infoViewID,isStop,hits,picUrl,proUrl1,proUrl2 from cj_product where isStop=false and id=" & iid
			data = db.GetData(sql)
			if not isArray(data) then message "id不存在！"
			classID = data(0,0)
			call setClass(classID)
			call setGenre(genreID)
			infoID = iid
			genreType = 1
			title = contentTag(data(1,0),0)
			if int(data(2,0)) > 0 then price = formatCurrency(data(2,0), 2) & "元" else price = "请咨询"
			manufacturer = data(3,0)
			productType = data(4,0)
			dateTime = FormatDateTime(cj_date(data(5,0)), 2)
			content = tidyContent(data(6,0))
			infoViewID = data(7,0)
			if cj_bool(data(8,0)) then isStop = "<font color=red>停产</font>" else isStop = "<font color='#29b629'>在产</font>"
			hits = data(9,0)
			if page = 1 then hits = hits & hitsJs(iid)
			picUrl = getInfoPic(data(10,0))
			proUrl1 = data(11,0)
			proUrl2 = data(12,0)
			if infoViewID > 0 then viewID = infoViewID else viewID = contentViewID
			infoUrl = getInfoUrl(genreType,iid,1)
			pn = getPrevNext(iid)
			prevInfo = pn(0)
			nextInfo = pn(1)
		end if
		getProduct = str
	end function

	public function getBook(ByVal iid)
		dim str : str = ""
		if iid > 0 then
			dim sql, data, pn
			genreID = 2
			sql = "select classID,userName,userAddr,userIP,title,dateTime,content,hits,isTop,isShow,userEmail,ReAdmin from cj_book where auditing=true and replyID=0 and id=" & iid
			data = db.GetData(sql)
			if not isArray(data) then message "id不存在或未审核！"
			classID = data(0,0)
			call setClass(classID)
			call setGenre(genreID)
			infoID = iid
			genreType = 2
			if int(data(11,0)) > 0 then
				userName = "<font color=""red"">管理员</font>"
			else
				userName = "" & contentTag(data(1,0),0)
			end if
			userAddr = "" & data(2,0)
			userIP = "" & data(3,0)
			title = "" & contentTag(data(4,0),0)
			dateTime = bookDate(data(5,0))
			hits = data(7,0)
			if page = 1 then hits = hits & hitsJs(iid)
			if cj_bool(data(8,0)) then isTop = "<font color=""red"">置顶</font>" else isTop = ""
			if infoViewID > 0 then viewID = infoViewID else viewID = contentViewID
			infoUrl = getInfoUrl(genreType,iid,1)
			pn = getPrevNext(iid)
			prevInfo = pn(0)
			nextInfo = pn(1)
			if cj_bool(data(9,0)) then
				content = "" & tidyContent(data(6,0))
				userEmail = "" & data(10,0)
			else
				content = "非公开留言"
				userEmail = "保密"
			end if
		end if
		getBook = str
	end function

	public function getOur(ByVal iid)
		dim str : str = ""
		if iid > 0 then
			dim sql, data
			sql = "select title,content,infoViewID,picUrl,isStop from cj_our where id=" & iid
			data = db.GetData(sql)
			if not isArray(data) then message "id不存在！"
			if data(4,0) then message "id已经禁用！"
			infoID = iid
			genreType = 4
			title = contentTag(data(0,0),0)
			content = tidyContent(data(1,0))
			infoViewID = data(2,0)
			picUrl = getInfoPic(data(3,0))
			infoUrl = getInfoUrl(genreType,iid,1)
			if infoViewID > 0 then viewID = infoViewID else viewID = ourViewID
		end if
	end function

	public function dateType(idateType, ByVal iDate)
		select case idateType
			case 1		: dateType = "<span class='date'>" & year(iDate) & "年" & month(iDate) & "月" & day(iDate) & "日</span>"
			case 2		: dateType = "<span class='date'>" & year(iDate) & "-" & month(iDate) & "-" & day(iDate) & "</span>"
			case 3		: dateType = "<span class='date'>" & month(iDate) & "-" & day(iDate) & "</span>"
			case else	: dateType = ""
		end select
	end function

	public function bookDate(ByVal iDate)
		select case dateDiff("d", iDate, now())
			case 0		: bookDate = "今天" & FormatDateTime(iDate, 3)
			case 1		: bookDate = "昨天" & FormatDateTime(iDate, 3)
			case 2		: bookDate = "前天" & FormatDateTime(iDate, 3)
			case 3		: bookDate = "大前天" & FormatDateTime(iDate, 3)
			case else	: bookDate = iDate
		end select
	end function

	public function getNewPic(ByVal iDate)
		iDate = cj_date(iDate)
		if dateDiff("d", iDate, now()) > newPic then
			getNewPic = ""
		else
			getNewPic = "<img class='new' src=""" & siteUrl & "view/style/image/new.gif"" />"
		end if
	end function

	public function getInfoPic(ByVal str)
		if len(trim(str)) > 0 then
			if left(str, 7) = "http://" then
			    getInfoPic = str
			else
			    str = replace(siteUrl & str, "{$uploadDir}", uploadDir)
			    getInfoPic = replace(str, "//" & uploadDir, "/" & uploadDir)
 			end if
		else
			getInfoPic = siteUrl & "view/style/image/nopic.gif"
		end if
	end function

	public function hitsJs(ByVal iid)
		hitsJs = "<script>$.post('" & getUrl("hits","","") & "',{g:" & genreType & ",i:" & iid & "})</script>"
	end function

	'***************************************************
	'函数名：reGenreHtml 替换大类自定义HTML
	'1 -- Gid 大类ID,多个ID用|分隔,0为全部大类ID
	'2 -- Css 如果是当前大类就要加上CSS
	'3 -- str 自定义HTML代码
	'***************************************************
	public function reGenreHtml(ByVal Gid, Css, ByVal strHtml)
		Gid = replace(trim(Gid), "{$genreID}", genreID)
		dim i, str, data, iGid, iCss(1)
		str = ""
		iGid = split(Gid, "|")
		if inStr(Css, "|") > 0 then
			iCss(0) = split(Css, "|")(0)
			iCss(1) = split(Css, "|")(1)
		end if
		for i = 0 to ubound(iGid)
			data = getGenreInfo(iGid(i))
			if isArray(data) then
				str = str & strHtml
				str = reAllGenre(data(0), str)
				if data(0) = genreID then
					str = replace(str, "{css}", iCss(0))
				else
					str = replace(str, "{css}", iCss(1))
				end if
			end if
		next
		reGenreHtml = str
	end function

	public function reAllGenre(ByVal Gid, ByVal str)
		if Gid = 0 or len(trim(str)) < 1 then exit function
		dim i
		i = getGenreInfo(Gid)
		if isArray(i) then
			str = replace(replace(replace("" & str, "{$genreID}", i(0)), "{$genreType}", i(1)), "{$genreName}", i(2))
			str = replace(replace(replace("" & str, "{$genreShortName}", i(3)), "{$genreUnit}", i(4)), "{$genreUrl}", getTypeUrl("g",Gid))
		end if
		reAllGenre = str
	end function

	public function reGenreClass(ByVal Gid, strHtml)
		if len(trim(strHtml)) < 1 then exit function
		Gid = replace(trim(Gid), "{$genreID}", genreID)
		dim str, data, i
		data = getGenreClass(Gid)
		if isArray(data) then
			for i = 0 to ubound(data)
				str = str & strHtml
				str = reAllClass(data(i), str)
			next
		end if
		reGenreClass = str
	end function

	public function reAllClass(ByVal cid, ByVal str)
		if len(trim(str)) < 1 then exit function
		dim i, j
		i = getClassInfo(cid)
		if isArray(i) then
			str = replace(replace(replace("" & str, "{$classID}", i(0)), "{$className}", i(2)), "{$classUrl}", getTypeUrl("l", cid))
			str = reAllGenre(i(1), str)
		end if
		ReAllclass = str
	end function

	public function getTypeUrl(ByVal infoName, ByVal iid)
		dim str
		if iid > 0 then
			str = infoName & "-" & iid
			if isHtml = false then
				str = "?/" & str
			end if
		end if
		getTypeUrl = siteUrl & str & "-1" & fileExt
	end function

	'gType: 1产品,2留言,3新闻,4简介 'p产品,b留言,a新闻,o简介
	public function getInfoUrl(ByVal gType, ByVal iid, ByVal iPage)
		dim str
		if iid > 0 then
			select case gType
				case 1 : str = "p-" & iid
				case 2 : str = "b-" & iid
				case 3 : str = "a-" & iid
				case 4 : str = "o-" & iid
			end select
			if isHtml = false then
				str = "?/" & str
			end if
		end if
		getInfoUrl = siteUrl & str & "-" & iPage & fileExt
	end function

	public function getUrl(ByVal gType, ByVal Gid, ByVal iid)
		dim str
		select case gType
			case "rss"		: str = "rss.xml" 'rss
			case "hits"		: str = gType & fileExt '点击数
			case "go"		: str = "go-" & Gid & fileExt '转跳网址
			case "re"		: str = "re-" & iid & fileExt & Gid '回复留言
			case "check"	: str = "check-" & Gid & fileExt '验证产品
		end select
		if isHtml = false then str = "query.asp?/" & str
		getUrl = siteUrl & str
	end function

	public function getPrevNext(ByVal iid)
		if iid < 1 then exit function
		dim rs, sql, str, data(1)
		sql = "select top 1 id,title from cj_"
		select case genreType
			case 1 : sql = sql & "product where isStop=false and genreID=" & genreID
			case 2 : sql = sql & "book where auditing=true and replyID=0"
			case 3 : sql = sql & "news where auditing=true and genreID=" & genreID
		end select
		if classID > 0 then sql = sql & " and classID=" & classID
		sql = sql & " and id<" & iid & " Order by id desc"
		set rs = db.exec(sql, 1)
		str = "<li class=""prveinfo"">上一" & genreUnit & genreShortName & "：<a href="""
		if not(rs.eof) then
			str = str & getInfoUrl(genreType,rs(0),1) & """ title=""" & rs(1) & """>" & rs(1)
		else
			str = str & classUrl & """>没有了.返回" & className
		end if
		data(0) = str & "</a></li>"
		sql = replace(replace(sql, "<", ">"), " desc", " asc")
		set rs = db.exec(sql, 1)
		str = "<li class=""nextinfo"">下一" & genreUnit & genreShortName & "：<a href="""
		if not(rs.eof) then
			str = str & getInfoUrl(genreType,rs(0),1) & """ title=""" & rs(1) & """>" & rs(1)
		else
			str = str & classUrl & """>没有了.返回" & className
		end if
		data(1) = str & "</a></li>"
		set rs = nothing
		getPrevNext = data
	end function

	'contentTag 标记内容里的标签
	public function contentTag(ByVal str, YesOrNo)
		if len(trim(str)) < 1 then exit function
		if YesOrNo = 1 then '还原标记
			str = replace(str, "{WWW_CJASP_COM_TAG$", "{$")
		else '加上标记
			str = replace(str, "{$", "{WWW_CJASP_COM_TAG$")
		end if
		contentTag = str
	end function

	'****************************************************
	'reView解析模板函数
	'****************************************************
	public function reView(ByVal str)
		if len(trim(str)) < 1 then exit function
		dim n, i, ii, Temp
		'解析自定义列表标签
		if inStr(str, "{$新闻自定义列表") > 0 then
			re.pattern = "\{\$新闻自定义列表\((.*?)\)\}([\s\S]*?)\{\/新闻自定义列表\}"
			set ii = re.execute(str)
			for each i in ii
				n = split(i.subMatches(0), ",")
				if ubound(n) <> 1 then
					message "{$新闻自定义列表(2个参数)}中参数为2个！"
				else
					str = replace(str, i, newsCustomList(n(0), n(1), i.subMatches(1)))
				end if
			next
			set ii = nothing
		end if
		if inStr(str, "{$产品自定义列表") > 0 then
			re.pattern = "\{\$产品自定义列表\((.*?)\)\}([\s\S]*?)\{\/产品自定义列表\}"
			set ii = re.execute(str)
			for each i in ii
				n = split(i.subMatches(0), ",")
				if ubound(n) <> 1 then
					message "{$产品自定义列表(2个参数)}中参数为2个！"
				else
					str = replace(str, i, productCustomList(n(0), n(1), i.subMatches(1)))
				end if
			next
			set ii = nothing
		end if
		if inStr(str, "{$留言自定义列表") > 0 then
			re.pattern = "\{\$留言自定义列表\((.*?)\)\}([\s\S]*?)\{\/留言自定义列表\}"
			set ii = re.execute(str)
			for each i in ii
				n = split(i.subMatches(0), ",")
				if ubound(n) <> 1 then
					message "{$留言自定义列表(2个参数)}中参数为2个！"
				else
					str = replace(str, i, bookCustomList(n(0), n(1), i.subMatches(1)))
				end if
			next
			set ii = nothing
		end if
		if inStr(str, "{$回复留言列表}") > 0 then
			re.pattern = "\{\$回复留言列表\}([\s\S]*?)\{\/回复留言列表\}"
			set ii = re.execute(str)
			for each i in ii
				str = replace(str, i, reBookCustomList(i.subMatches(0)))
			next
			set ii = nothing
		end if
		if inStr(str, "{$大类连接") > 0 then
			re.pattern = "\{\$大类连接\((.*?)\)\}([\s\S]*?)\{\/大类连接\}"
			set ii = re.execute(str)
			for each i in ii
				n = split(i.subMatches(0), ",")
				if ubound(n) <> 1 then
					message "{$大类连接(2个参数)}中参数为2个！参数1：大类ID，2：当为当前的大类时要加入的CSS名称。"
				else
					str = replace(str, i, reGenreHtml(n(0), n(1), i.subMatches(1)))
				end if
			next
			set ii = nothing
		end if
		if inStr(str, "{$栏目导航") > 0 then
			re.pattern = "\{\$栏目导航\((.*?)\)\}([\s\S]*?)\{\/栏目导航\}"
			set ii = re.execute(str)
			for each i in ii
				str = replace(str, i, reGenreClass(i.subMatches(0), i.subMatches(1)))
			next
			set ii = nothing
		end if
		if inStr(str, "{$time") > 0 then
			re.pattern = "\{\$time\((.*?)\)\}([\s\S]*?)\{\/time\}"
			set ii = re.execute(str)
			for each i in ii
				str = replace(str, i, reDate(i.subMatches(0), i.subMatches(1)))
			next
			set ii = nothing
		end if
		str = reCommon(str) '解析模板中公共的标签
		if inStr(str, "{$新闻列表") > 0 then '解析文章列表标签
			re.pattern = "\{\$新闻列表\((.*?)\)\}"
			set ii = re.execute(str)
			for each i in ii
				n = split(i.subMatches(0), ",")
				if ubound(n) <> 10 then
					message "{$新闻列表(11个参数)}中参数为11个！"
				else
					Temp = newsList(n(0), n(1), n(2), n(3), n(4), n(5), n(6), n(7), n(8), n(9), n(10))
					str = replace(str, i, Temp)
				end if
			next
			set ii = nothing
		end if
		if inStr(str, "{$产品列表") > 0 then '解析产品列表标签
			re.pattern = "\{\$产品列表\((.*?)\)\}"
			set ii = re.execute(str)
			for each i in ii
				n = split(i.subMatches(0), ",")
				if ubound(n) <> 11 then
					message "{$产品列表(12个参数)}中参数为12个！"
				else
					Temp = productList(n(0), n(1), n(2), n(3), n(4), n(5), n(6), n(7), n(8), n(9), n(10), n(11))
					str = replace(str, i, Temp)
				end if
			next
			set ii = nothing
		end if
		if inStr(str, "{$简介列表") > 0 then '解析简介列表标签
			re.pattern = "\{\$简介列表\((.*?)\)\}"
			set ii = re.execute(str)
			for each i in ii
				n = split(i.subMatches(0), ",")
				if ubound(n) <> 3 then
					message "{$简介列表(4个参数)}中参数为4个！"
				else
					str = replace(str, i, ourList(n(0), n(1), n(2), n(3)))
				end if
			next
			set ii = nothing
		end if
		if inStr(str, "{$留言列表") > 0 then '解析留言列表标签
			re.pattern = "\{\$留言列表\((.*?)\)\}"
			set ii = re.execute(str)
			for each i in ii
				n = split(i.subMatches(0), ",")
				if ubound(n) <> 8 then
					message "{$留言列表(9个参数)}中参数为9个！"
				else
					str = replace(str, i, bookList(n(0), n(1), n(2), n(3), n(4), n(5), n(6), n(7), n(8)))
				end if
			next
			set ii = nothing
		end if
		if inStr(str, "{$conLen") > 0 then '解析取指定字数的内容标签
			re.pattern = "\{\$conLen\((\d+)\)\}"
			set ii = re.execute(str)
			for each i in ii
				n = int(i.subMatches(0))
				if n > 0 then str = replace(str, i, getStrContent(content, n))
			next
			set ii = nothing
		end if
		if inStr(str, "{$date") > 0 then '解析日期
			re.pattern = "\{\$date\((.*?)\)\}"
			set ii = re.execute(str)
			for each i in ii
				n = reDate(now(), i.subMatches(0))
				str = replace(str, i, n)
			next
			set ii = nothing
		end if
		if inStr(str, "{$curCss") > 0 then '解析菜单里的style
			re.pattern = "\{\$curCss\((.*?)\)\}"
			set ii = re.execute(str)
			for each i in ii
				n = split(i.subMatches(0), ",")
				if ubound(n) <> 2 then
					message "{$curCss(3个参数)}中参数为3个！"
				else
					Temp = n(2)
					if trim(genreType) = trim(n(0)) then Temp = n(1)
					str = replace(str, i, Temp)
				end if
			next
			set ii = nothing
		end if
		if inStr(str, "{$url") > 0 then '解析项目链接
			re.pattern = "\{\$url\((.*?)\)\}"
			set ii = re.execute(str)
			for each i in ii
				redim j(2)
				dim k, m
				m = array("", "", "")
				k = split(i.subMatches(0), ",")
				j(0) = k(0)
				if ubound(k) > 0 then j(1) = k(1)
				if ubound(k) > 1 then j(2) = k(2)
				Temp = ""
				select case j(0)
					case "g","l" : Temp = getTypeUrl(j(0), j(1))
					case "a","b","o","p"
						if j(0) = "o" then Temp = getInfoUrl(4, j(1), 1) else Temp = getInfoUrl(genreType, j(1), 1)
					case else Temp = getUrl(j(0), j(1), iid)
				end select
				str = replace(str, i, Temp)
			next
			set ii = nothing
		end if
		str = replace(str, "{$runTime}", formatNumber((Timer - beginTime) * 1000, 2) & "ms")
		reView = str
	end function

	public function reDate(ByVal iTime, ByVal str)
		if len("" & str) < 1 then exit function
		dim week : week = array("", "天", "一", "二", "三", "四", "五", "六")
		iTime = cj_date(iTime)
		str = replace(str, "{d}", day(iTime))
		str = replace(str, "{m}", month(iTime))
		str = replace(str, "{y}", year(iTime))
		str = replace(str, "{h}", hour(iTime))
		str = replace(str, "{mi}", minute(iTime))
		str = replace(str, "{s}", second(iTime))
		str = replace(str, "{w}", "星期" & week(weekday(iTime)))
		reDate = str
	end function

	'解析网站公共标签
	public function reConfig(ByVal str)
		if len("" & str) < 1 then exit function
		dim i, ii, j
		'解析系统配置标签
		if inStr(str, "{$C(") > 0 then
			for j = 0 to 1
				re.pattern = "\{\$C\((.*?)\)\}"
				set ii = re.execute(str)
				for each i in ii
					str = replace(str, i, getConfig(i.subMatches(0)))
				next
				set ii = nothing
			next
		end if
		str = replace(str, "{$siteUrl}", siteUrl)
		str = replace(str, "{$siteName}", siteName)
		str = replace(str, "{$siteTitle}", siteTitle)
		reConfig = str
	end function

	public function reGenre(ByVal str)
		if len("" & str) < 1 then exit function
		str = replace(str, "{$genreID}", genreID)
		str = replace(str, "{$genreName}", genreName)
		str = replace(str, "{$genreShortName}", genreShortName)
		str = replace(str, "{$genreUnit}", genreUnit)
		str = replace(str, "{$genreUrl}", genreUrl)
		reGenre = str
	end function

	public function reClass(ByVal str)
		str = replace(replace(replace("" & str, "{$classID}", classID), "{$className}", className), "{$classUrl}", classUrl)
		Reclass = str
	end function

	public function reCommon(ByVal str)
		if len("" & str) < 1 then exit function
		str = reConfig(str)
		str = reGenre(str)
		str = reClass(str)
		if page > 1 then str = replace(str, "{$页码}", " 第" & page & "页") else str = replace(str, "{$页码}", "")
		if infoID > 0 then content = addLink(content)
		str = replace(str, "{$picUrl}", picUrl)
		str = replace(str, "{$title}", title)
		str = replace(str, "{$content}", reConfig(content)) '解析内容里的公共标签
		str = replace(str, "{$author}", author)
		str = replace(str, "{$copyFrom}", copyFrom)
		str = replace(str, "{$hits}", hits)
		str = replace(str, "{$dateTime}", dateTime)
		str = replace(str, "{$infoUrl}", infoUrl)
		str = replace(str, "{$infoID}", infoID)
		str = replace(str, "{$prevInfo}", prevInfo)
		str = replace(str, "{$nextInfo}", nextInfo)
		'解析特有标签
		str = replace(str, "{$price}", price)
		str = replace(str, "{$manufacturer}", manufacturer)
		str = replace(str, "{$productType}", productType)
		str = replace(str, "{$isStop}", isStop)
		str = replace(str, "{$userName}", userName)
		str = replace(str, "{$userIP}", userIP)
		str = replace(str, "{$isTop}", isTop)
		str = replace(str, "{$page}", showPage(infoTotal, page, rows, pageUrl))
		str = replace(str, "{$rss}", "<a id='rss' href=""" & getUrl("rss","","") & """ target=""_blank""><img src=""" & siteUrl & "view/style/image/rss.gif"" /></a>")
		reCommon = str
	end function

	public function addLink(ByVal str)
		str = str & ""
		if len(str) = 0 then exit function
		dim ii, i, j, tag1, tag2, data()
		tag1 = "【WWW_CJASP_COM_KEYWORD_"
		tag2 = "_WWW_CJASP_COM_KEYWORD】"
		j = 0
		str = replace(replace(str, tag1, ""), tag2, "")
		re.pattern = "(<a\s+[^>]*>[\s\S]*?<\/a>)|(<(\/)*\w+[^>]*>)"
		set ii = re.execute(str)
		for each i in ii
			redim preserve data(j)
			data(j) = i
			str = replace(str, i, tag1 & j & tag2)
			j = j + 1
		next
		set ii = nothing
		str = reInnerLink(str)
		j = j - 1
		do while j > -1
			str = replace(str, tag1 & j & tag2, data(j))
			j = j - 1
		loop
		str = replace(replace(str, tag1, ""), tag2, "")
		addLink = str
	end function

	public function reInnerLink(ByVal str)
		dim rs, tCc, data, i, iKey, nKey
		tCc = "innerLinks"
		'if fileCacheExpire(tCc) then '检查缓存是否存在 文件缓存
		if appCacheCheck(tCc) then '检查缓存是否存在
			set rs = db.exec("select linkName,linkAddr,linkNumber from cj_link Order By id Desc", 1)
			if not rs.eof then
				data = rs.getString(,,"|||",vbCr,"")
			else
				data = siteName & "|||" & siteUrl & "|||1" & vbCr
			end if
			set rs = nothing
			setAppCache tCc, data '生成缓存
			'fileCacheWrite tCc, data '写入文件 文件缓存
		else
			data = getAppCache(tCc) '读取缓存
			'data = fileCacheLoad(tCc) '读取缓存 文件缓存
		end if
		iKey = split(data, vbCr)
		for i = 0 to ubound(iKey) - 1
			nKey = split(iKey(i), "|||")
			str = replace(str, nKey(0), "<a href=""" & nKey(1) & """ title=""" & nKey(0) & """ target=""_blank"">" & nKey(0) & "</a>", 1, nKey(2))
		next
		reInnerLink = str
	end function

	public function isAdmin()
		dim rs, i, iName, iPass
		iName = getCookie("adminName")
		iPass = getCookie("password")
		if iName = "" or iPass = "" then
			isAdmin = false
			exit function
		end if
		set rs = db.exec("select id,adminName,nickName,password,loginIP,loginTime,loginNumber,isSuper from cj_admin where adminName='" & iName & "' and password='" & iPass &"' and isStop=false", 1)
		if not rs.eof then
			for i = 0 to rs.Fields.count - 1
				adminInfo(i) = rs(i)
			next
			setCookie "adminName", adminInfo(1)
			setCookie "password", adminInfo(3)
			isAdmin = true
		else
			isAdmin = false
		end if
		set rs = nothing
	end function

	public function setCookie(names, val)
		if names <> "" then
			response.cookies(names) = val
			response.cookies(names).expires = Date + cookieTime
		end if
	end function

	public function getCookie(names)
		if names <> "" then getCookie = reChar(request.cookies(names)) else getCookie = ""
	end function

	public function tidyContent(ByVal str)
		if len("" & str) < 1 then exit function
		str = replace("" & str, "{$uploadDir}", uploadDir)
		str = contentTag(str, 0)
		if inStr(str, "[page]") > 0 then
			dim data, strp, iTotal
			strp = ""
			data = split(str, "[page]")
			iTotal = ubound(data) + 1
			if page > iTotal then page = iTotal
			if page <> iTotal then strp = "</p>"
			str = data(page - 1) & strp & contentPage(genreID, infoID, iTotal, page)
			if left(str, 4) = "</p>" then str = right(str, len(str) - 4)
			're.pattern = "^(([^<]*>)[^<]{0,100})(?:<p|<img|<br|<li)*"
			'str = right(str, len(str) - BeginPoint)
			'set Matches = regEx.execute(str)
			'if Matches.count > 0 then
				'tidyContent = BeginPoint + len(Matches(0).subMatches(1)) + 1
			'else
				'tidyContent = BeginPoint
			'end if
		end if
		tidyContent = str
	end function

	public function go(url)
		if len("" & url) < 1 then
			response.redirect request.serverVariables("http_referer")
		else
			if left(url, 7) <> "http://" then url = "http://" & url
			response.redirect url
		end if
	end function

	public function toEnglish(ByVal fn)
		if len("" & fn) < 1 then toEnglish = "" : exit function
		re.pattern = "([^\w]+)"
		fn = re.replace(fn, "")
		toEnglish = fn
	end function

	'取得模板文件
	public function getViewIdFile(ByVal vid)
		dim fn : fn = root & cacheDir & "/view/v_" & vid & viewExt
		if isFile(fn) = false then
			createView(vid)
		end if
		getViewIdFile = loadFile(fn, 1)
	end function

	public function viewFileCheck(ByVal fn)
		viewFileCheck = (isFile(root & cacheDir & "/view/" & fn & viewExt) = false)
	end function

	'写入模板文件
	public function viewFileWrite(fn, ByVal content)
		viewFileWrite = addFile(root & cacheDir & "/view/" & fn & viewExt, content)
	end function

	'取得生成的模板文件
	public function viewFileLoad(ByVal fn)
		viewFileLoad = loadFile(root & cacheDir & "/view/" & fn & viewExt, 1)
	end function

	'创建模板文件，vid 参数：创建指定的模板ID，0创建所有模板
	public function createView(ByVal vid)
		dim rs, sql, str, Temp, i, ii, n
		Temp = false
		sql = "select id,viewContent from cj_view where isStop=false"
		if vid > 0 then sql = sql & " and id=" & vid
		set rs = db.exec(sql, 1)
		if rs.eof then
			set rs = nothing
			Temp = false
			exit function
		end if
		do until rs.eof
			str = rs(1)
			if inStr(str, "{$my_") > 0 then '替换自定义标签
				re.pattern = "\{\$my_([^\}]*?)\}"
				set ii = re.execute(str)
				for each i in ii
					n = customView(i.subMatches(0))
					str = replace(str, i, n)
				next
				set ii = nothing
			end if
			're.pattern = "\s*(<[^>]+>)\s*"
			'str = re.replace(str, "$1")
			'去掉标记前后的空白
			re.pattern = "\s+<\s*"
			str = re.replace(str, "<")
			re.pattern = "\s*>\s+"
			str = re.replace(str, ">")
			call viewFileWrite("v_" & rs(0), str)
		rs.moveNext : loop
		Temp = true
		set rs = nothing
		createView = Temp
	end function

	public function customView(ByVal val)
		if len("" & val) < 1 then exit function
		re.pattern = "([^\w\-]+)"
        val = re.replace(val, "")
		dim rs, str
		str = ""
		if isFile(root & cacheDir & "/view/my_" & val & viewExt) = false then
			set rs = db.exec("select customTag,customContent from cj_custom where customTag='" & replace(val, "my_", "") & "'", 1)
			if rs.eof then
				set rs = nothing
				customView = ""
				exit function
			end if
			str = rs(1)
			call viewFileWrite("my_" & lcase(rs(0)), str)
			set rs = nothing
		else
			str = viewFileLoad("my_" & lcase(val))
		end if
		customView = str
	end function

	'**************************************************
	'检测文件是否存在,存在返回true,否则false
	'**************************************************
	public function isFile(ByVal fn)
		on error resume next
		isFile = false
		if inStr(fn, ":") < 1 then
			fn = server.mapPath(fn)
		end if
		if fso.fileExists(fn) then
			isFile = true
		end if
	end function

	'检查缓存文件是否过期,过期返回true
	public function fileCacheExpire(ByVal fn)
		if cacheExpireTime <= 0 then
			fileCacheExpire = false
			exit function
		end if
		fileCacheExpire = true
		dim ret, fd, ft
		fn = root & cacheDir & "/data/" & fn & viewExt
		if cacheExpireTime > 0 and isFile(fn) = true then
			set fd = fso.GetFile(server.mapPath(fn))
			ft = fd.DateCreated
			if dateDiff("s", cdate(ft), now()) < 60 * cacheExpireTime then
				fileCacheExpire = false
			end if
			set fd = nothing
		end if
	end function

	'写入缓存文件
	public function fileCacheWrite(fn, ByVal content)
		fileCacheWrite = addFile(root & cacheDir & "/data/" & fn & viewExt, content)
	end function

	'取得生成的缓存文件
	public function fileCacheLoad(ByVal fn)
		fileCacheLoad = loadFile(root & cacheDir & "/data/" & fn & viewExt, 1)
	end function

    '删除指定文件
    public function deleteFile(ByVal fn)
        on error resume next
        deleteFile = false
		if inStr(fn, ":") < 1 then
			fn = server.mapPath(fn)
		end if
        if isFile(fn) then
            fso.deleteFile fn
            errorLog
            deleteFile = true
        end if
    end function

	'删除缓存目录下的所有文件
	public function fileCacheDelete()
		on error resume next
		dim dirs
		dirs = server.mapPath(root & cacheDir)
		if fso.FolderExists(dirs) then
			fso.DeleteFolder(dirs)
		end if
		errorLog
	end function

	public function loadFile(ByVal fn, Char)
		if inStr(fn, ":") < 1 then
			fn = server.mapPath(fn)
		end if
		if isFile(fn) = false then
			log(fn & " 文件不存在")
			message "文件 " & fn & " 丢失！"
		end if
		select case Char
			case 1 : Char = "utf-8"
			case 2 : Char = "gb2312"
			case 3 : Char = "gbk"
			case else : Char = "utf-8"
		end select
		dim obj
		set obj = server.createObject("adodb.stream")
		obj.type = 2
		obj.mode = 3
		obj.charset = Char
		obj.open()
		obj.LoadFromFile(fn)
		loadFile = obj.readText
		obj.close
		set obj = nothing
	end function

	public function mkdir(ByVal Paths)
		if len("" & Paths) < 1 then
			mkdir = false
			exit function
		end if
		on error resume next
		dim dir
		Paths = replace(Paths, "\", "/")
		if right(Paths, 1) <> "/" then Paths = Paths & "/"
		do while inStr(2, Paths, "/") > 1
			dir = dir & left(Paths, inStr(2, Paths, "/") - 1)
			Paths = mid(Paths, inStr(2, Paths, "/"))
			if not fso.FolderExists(server.mapPath(dir)) then
				fso.CreateFolder(server.mapPath(dir))
			end if
			if err then
				err.clear
				mkdir = false
				exit function
			end if
		loop
		mkdir = true
	end function

	public function addFile(fn, ByVal content)
		if len("" & fn) < 1 then
			addFile = false
			exit function
		end if
		if inStr(fn, "/") > 0 then
			call mkdir(left(fn, inStrRev(fn, "/") - 1))
		end if
		dim obj, obj1
		set obj = server.createObject("adodb.Stream")
		obj.type = 2
		obj.mode = 3
		obj.charset = "utf-8"
		obj.open()
		obj.writetext(content)
		obj.position = 3
		set obj1 = server.createObject("adodb.Stream")
		obj1.mode = 3
		obj1.type = 1
		obj1.open()
		obj.copyTo(obj1)
		obj1.saveToFile server.mapPath(fn), 2
		obj.flush
		obj.close
		set obj = nothing
		set obj1 = nothing
		addFile = true
	end function

	public function hec(ByVal str)
		Hec = replace(server.HTMLEncode("" & str),  chr(39), "&#39;")
	end function

	public function reChar(ByVal str)
		if len("" & str) < 1 then exit function
		dim arrChar, nChar, i
		arrChar = "+,',%,^,&,?,(,),<,>,[,],{,},/,\,;,:," & chr(34) & "," & chr(0) & ",--"
		nChar = split(arrChar, ",")
		for i = 0 to ubound(nChar)
			str = replace(str, nChar(i), "")
		next
		str = replace(str, "@@", "@")
		reChar = str
	end function

	public function int(str)
		if isNumeric(trim(str)) then int = fix(cdbl(trim(str))) else int = 0
	end function

	public function int1(str)
		str = int(str)
		if str <= 0 then int1 = 1 else int1 = str
	end function

	public function cj_date(ByVal sDate)
		sDate = trim(sDate)
		if isDate(sDate) then cj_date = cdate(sDate) else cj_date = now()
	end function

	public function cj_bool(str)
		cj_bool = false
		str = lcase(trim(str))
		if str = "true" then
			cj_bool = true
		elseif isNumeric(str) then
			if int(str) <> 0 then cj_bool = true else cj_bool = false
		end if
	end function

	public function getStrContent(ByVal iCon, iConLen)
		if len("" & iCon) < 1 then exit function
		iCon = noCode(iCon)
		iConLen = int(iConLen)
		dim strCon : strCon = ""
		if iConLen > 0 then strCon = getLength(iCon, iConLen)
		strCon = replace(replace(replace("" & strCon, "[page]", ""), ">", "&gt;"), "<", "&lt;")
		getStrContent = strCon & "..."
	end function

	public function getLength(ByVal str, ilen)
		if len("" & str) < 1 then exit function
		str = replace(replace(replace(replace("" & str, "&nbsp;", " "), "&quot;", chr(34)), "&gt;", ">"), "&lt;", "<")
		dim b, c, d, e, temp
		b = len(str)
		c = 0
		temp = str
		ilen = int(ilen)
		for e = 1 to b
			d = abs(asc(mid(str, e, 1)))
			if d > 255 then c = c + 2 else c = c + 1
			if c >= ilen then
				temp = left(str, e)
				exit for
			end if
		next
		temp = replace(replace(replace(replace(temp, " ", "&nbsp;"), chr(34), "&quot;"), ">", "&gt;"), "<", "&lt;")
		getLength = temp
	end function

	public function wordCount(ByVal str)
		if len("" & str) < 1 then exit function
		dim a, b, c, d, e
		str = replace(replace(replace(replace("" & str, "&nbsp;", ""), "&quot;", ""), "&gt;", ""), "&lt;", "")
		str = replace(replace(replace(replace("" & str, chr(34), ""), " ", ""), "<", ""), ">", "")
		a = (len("赤金") = 2)
		if a then
			b = len(str)
			c = b
			for e = 1 to b
				d = asc(mid(str, e, 1))
				if d < 0 then d = d + 65536
				if d > 255 then
					c = c + 1
				end if
			next
			wordCount = c
		else
			wordCount = len(str)
		end if
	end function

	public function isTest(ByVal Val, patt)
		if len("" & Val) = 0 then exit function
		dim str, i, j, k, ii, data
		str = Val
		re.pattern = patt
		if re.test(Val) then
			set ii = re.execute(str)
			for each i in ii
				k = i.subMatches.count - 1
				redim data(k)
				for j = 0 to k
					data(j) = i.subMatches(j)
				next
				str = data
			next
			set ii = nothing
		end if
		isTest = str
	end function

	'**************************************************
	'分页函数：showPage
	'rsSum 总数量,CurrentPage 当前页, nPage 每页数, Url 文件连接
	'**************************************************
	public function showPage(rsSum, ByVal CurrentPage, ByVal nPage, Url)
		dim SumPage, str, i, p, np, inp
		p = Url & "-"
		if rsSum > nPage then
			if nPage = 0 then
				showPage = ""
				exit function
			end if
			SumPage = rsSum \ nPage
			if rsSum mod nPage <> 0 then SumPage = SumPage + 1
			if CurrentPage > SumPage then CurrentPage = SumPage
			str = "<div class='page'><span>共" & rsSum & genreUnit & genreShortName & "," & SumPage & "页," & nPage & genreUnit & "/页</span>"
			if CurrentPage > 1 then str = str & "<a href='" & p & "1" & fileExt & "'>&lt;&lt;</a><a href='" & p & (CurrentPage - 1) & fileExt & "'>&lt;</a>"
			if (CurrentPage - 4) <= 0 or SumPage < 10 then
				i = 1
				do while (i < 10)
					str = str & pageHref(i, CurrentPage, p)
					if i = SumPage then exit do
					i = i + 1
				loop
			elseif (CurrentPage + 4) >= SumPage then
				i = SumPage - 8
				do while (i <= SumPage)
					str = str & pageHref(i, CurrentPage, p)
					i = i + 1
				loop
			else
				i = CurrentPage - 4
				do while (i < CurrentPage + 5)
					str = str & pageHref(i, CurrentPage, p)
					i = i + 1
				loop
			end if
			if CurrentPage < SumPage then
				str = str & "<a href='" & p & (CurrentPage + 1) & fileExt & "'>&gt;</a><a href='" & p & SumPage & fileExt & "'>&gt;&gt;</a>"
			end if
			str = str & inp & "</div>"
		else
			if rsSum > 0 then
				str = "<div class='page'><span>共" & rsSum & genreUnit & genreShortName & "," & nPage & genreUnit & "/页</span>" & inp & "</div>"
			end if
		end if
		showPage = str
	end function

	public function pageHref(ByVal i, ByVal CurrentPage, ByVal p)
		if i = CurrentPage then pageHref = "<b>" & i & "</b>" else pageHref = "<a href=""" & p & i & fileExt & """>" & i & "</a>"
	end function

	'rsSum 总页数 CurrentPage 当前页数
	public function contentPage(ByVal Gid, ByVal iid, ByVal rsSum, ByVal CurrentPage)
		dim str, i, nPage, sFlag, eFlag
		nPage = 10 '每页显示的页数
		if rsSum > nPage then
			if (CurrentPage mod nPage) <> 0 then
				sFlag = (CurrentPage \ nPage) * nPage + 1
				eFlag = sFlag + nPage - 1
			else
				sFlag = CurrentPage - nPage + 1
				eFlag = CurrentPage
			end if
		else
			sFlag = 1
			eFlag = rsSum
		end if
		if eFlag > rsSum then eFlag = rsSum
		str = str & "<div id='pages' class='page'>"
		if CurrentPage > 1 then
			if CurrentPage > nPage and CurrentPage <= rsSum then
				str = str & "<a href='" & getInfoUrl(genreType, iid, sFlag - 1) & "' >&lt;&lt;</a>"
			end if
			str = str & "<a href='" & getInfoUrl(genreType, iid, CurrentPage - 1) & "'>&lt;</a>"
		end if
		for i = sFlag to eFlag
			if i = CurrentPage then
				str = str & "<b>" & i & "</b>"
			else
				str = str & "<a href='" & getInfoUrl(genreType, iid, i) & "'>" & i & "</a>"
			end if
		next
		if eFlag < rsSum then str = str & "..."
		if CurrentPage < rsSum then
			str = str & "<a href='" & getInfoUrl(genreType, iid, CurrentPage + 1) & "'>&gt;</a>"
			if rsSum > eFlag then
				str = str & "<a href='" & getInfoUrl(genreType, iid, eFlag + 1) & "'>&gt;&gt;</a>"
			end if
		end if
		str = str & "</div>"
		contentPage = str
	end function

    '***************************************************
	'* 转JSON
	'* @param msg string|array 提示信息
	'* @param error int 错误代码
	'* @returns {JSON}
	'*/
	'***************************************************
	public function json(msg, error)
		response.addHeader "content-Type", "application/json; charset=UTF-8"
		dim hash
		set hash = jsObject()
		hash("error") = error
		hash("message") = msg
		hash.flush
		call db.close()
		response.end
	end function

	public function message(msg)
		if request("ajax") <> "" then
		    json msg, 1
		end if
		%><!--#include file="../view/web/message.asp"--><%
		call db.close()
		err.clear
		response.end()
	end function

	public function rand(Num)
		if int(Num) = 0 then Num = 6
		dim All, i, j
		All = "0123456789abcdefghijklmnopqrstuvwxyz"
		randomize Timer
		for i = 0 to Num - 1
			j = j & mid(All, fix(35 * Rnd) + 1, 1)
		next
		rand = j
	end function

	'**************************************************
	'作用：检测组件, str组件名
	'**************************************************
	public function checkObject(ByVal str)
		on error resume next
		dim obj, ret
		ret = false
		set obj = server.createObject(str)
		if err <> - 2147221005 then ret = true
		set obj = nothing
		checkObject = ret
	end function

	public function checkPost()
		dim ServerA, ServerB
		ServerA = cstr(comeUrl) 'request.serverVariables("Http_Referer")
		ServerB = cstr(request.serverVariables("Server_Name"))
		if mid(ServerA, 8, len(ServerB)) <> ServerB then message "不好意思！不可以远程提交数据喔！"
		checkPost = true
	end function

	public function noCode(ByVal str)
		if isNull(str) or trim(str) = "" then
			noCode = ""
			exit function
		end if
		re.pattern = "(<[^>]*>)"
		str = re.replace(str, "")
		re.pattern = "\[page\]"
		str = re.replace(str, "")
		str = replace(str, "'", "")
		str = replace(str, " ", "")
		str = replace(str, "&nbsp;", "")
		str = replace(str, "*", "")
		str = replace(str, chr(34), "")
		str = replace(str, chr(9), "")
		str = replace(str, vbCrLf, "")
		str = reChar(trim(str))
		noCode = str
	end function

	public function enCode(ByVal str)
		if isNull(str) or trim(str) = "" then
			enCode = ""
			exit function
		end if
		str = replace(str, "&", "&amp;")
		str = replace(str, ">", "&gt;")
		str = replace(str, "<", "&lt;")
		str = replace(str, chr(32), "&nbsp;")
		str = replace(str, chr(9), "&nbsp;&nbsp;&nbsp;&nbsp;")
		str = replace(str, chr(34), "&quot;")
		str = replace(str, chr(39), "&#39;")
		str = replace(str, chr(13), "")
		str = replace(str, chr(10), "")
		enCode = str
	end function

	'全角转换为半角
	public function quanToBan(ByVal str)
		if len(str) = 0 then
			quanToBan = ""
			exit function
		end if
		dim i, j, k, str1
		str1 = ""
		for i = 1 to len(str)
			k = mid(str, i, 1)
			j = ascw(k)
			if j < 0 then
				j = j + 65536
				if j > 65280 and j < 65375 then
					str1 = str1 & chr(j - 65248)
				else
					str1 = str1 & k
				end if
			else
				str1 = str1 & k
			end if
		next
		quanToBan = str1
	end function

	public function toSize(ByVal value)
		dim data, i
		if not isNumeric(value) then value = int(value)
		data = array("B", "K", "M", "G", "T")
		i = 0
		do while value >= 1024
			value = value / 1024
			i = i + 1
		loop
		toSize = formatNumber(value, 2) & data(i)
	end function

	public function log(ByVal str)
		on error resume next
		dim t, dir, logFile, logCon
		t = now()
		logFile = root & "log/" & year(t) & right("0" & month(t), 2) & right("0" & day(t), 2) & ".log"
		if isFile(logFile) then '存在日志，追加日志
			str = loadFile(logFile, 1) & chr(13) & t & chr(13) & str
		end if
		call addFile(logFile, str)
	end function

    public function errorLog()
        if debug and err.number <> 0 then
            dim str
            errorTotal = errorTotal + 1
            str = fileName & "?" & lcase(request.serverVariables("QUERY_STRING"))
            str = str & ", " & errorTotal & "错误,"
            str = str & "代码:0x" & hex(err.number) & ","
            str = str & "描述:" & err.description & ","
            str = str & "来源:" & err.source
            log str
        end if
    end function

	'************************************************************
	'getConfig 取得配置缓存
	'************************************************************
	public function getConfig(cName)
		getConfig = application(cacheName & "_Config_" & cName)
	end function

	'************************************************************
	'setGenre 根据大类ID 赋值全局变量
	'************************************************************
	public function setGenre(ByVal id)
		dim temp, item
		item = getGenreInfo(id)
		if isArray(item) and ubound(item) = 5 then
			genreID = item(0)
			genreType = item(1)
			genreName = item(2)
			genreShortName = item(3)
			genreUnit = item(4)
			genreViewID = item(5)
			genreUrl = getTypeUrl("g", item(0))
		end if
	end function

	'************************************************************
	'getGenreInfo 取得大类ID下的信息
	'************************************************************
	public function getGenreInfo(ByVal id)
		dim temp, item
		temp = getAppCache("genreInfo_" & id)
		if temp = "" then
			updateCache "genre"
			temp = getAppCache("genreInfo_" & id)
		end if
		if temp <> "" then
			item = split(temp, "|||")
			if ubound(item) = 5 then
				getGenreInfo = item
			end if
		end if
	end function

	'************************************************************
	'getGenreAllInfo 取得所有大类
	'************************************************************
	public function getGenreAllInfo()
		dim temp, item, n, i, data()
		if getAppCache("genreAll") = "" then
			updateCache "genre"
		end if
		temp = getAppCache("genreAll")
		if temp <> "" then
			item = split(temp, ",") '分割读取的数据
			for i = 0 to ubound(item)
				n = getAppCache("genreInfo_" & item(i))
				if n <> "" then
					redim preserve data(i)
					data(i) = split(n, "|||")
				end if
			next
			getGenreAllInfo = data
		end if
	end function

	'************************************************************
	'Setclass 根据栏目ID 赋值全局变量
	'************************************************************
	public function setClass(ByVal id)
		dim temp, item
		item = getClassInfo(id)
		if isArray(item) and ubound(item) = 4 then
			classID = item(0) '栏目ID
			genreID = item(1) '栏目所属大类ID
			className = item(2) '栏目名
			classViewID = item(3) '栏目模板ID
			contentViewID = item(4) '栏目的内容模板ID
			classUrl = getTypeUrl("l", item(0)) '栏目链接
		end if
	end function

	'************************************************************
	'getClassInfo 取得分类ID下的信息，如果大类ID为0，则取所有分类ID
	'************************************************************
	public function getClassInfo(ByVal id)
		dim temp, item
		temp = getAppCache("classInfo_" & id)
		if temp = "" then
			updateCache "class"
			temp = getAppCache("classInfo_" & id)
		end if
		if temp <> "" then
			item = split(temp, "|||")
			if ubound(item) = 4 then
				getClassInfo = item
			end if
		end if
	end function

	'************************************************************
	'getGenreclass 取得大类ID下的所有分类ID，如果大类ID为0，则取所有分类ID
	'************************************************************
	public function getGenreClass(ByVal id)
		dim temp, item
		if getAppCache("classAll") = "" then
			updateCache "allclass"
		end if
		if id < "1" then
			temp = getAppCache("classAll")
		else
			temp = getAppCache("genreClass_" & id)
		end if
		if temp <> "" then
			getGenreclass = split(temp, ",")
		end if
	end function

	'************************************************************
	'setAppCache 设置缓存对象的值
	'cName 缓存名称，Val 设置的缓存值
	'返回：true 成功，false 失败
	'************************************************************
	public function setAppCache(ByVal cName, ByVal Val)
		setAppCache = false
		if cName <> "" then
			application.lock
			application(cacheName & "_" & cName) = Val
			application.unLock
			setAppCache = true
		end if
	end function

	'************************************************************
	'getAppCache 读取缓存值, cName 缓存名称, 返回：缓存值
	'************************************************************
	public function getAppCache(ByVal cName)
		getAppCache = application(cacheName & "_" & cName)
	end function

	'************************************************************
	'appCacheCheck 判断缓存是否存在, cName 缓存名称
	'返回：true 不存在，false 存在
	'************************************************************
	public function appCacheCheck(ByVal cName)
		appCacheCheck = (application(cacheName & "_" & cName) <> "")
	end function

	'************************************************************
	'appCacheDelete 手工删除一个cName缓存对象
	'************************************************************
	public function appCacheDelete(ByVal cName)
		if inStr(cName, cacheName) = 0 then
			cName = cacheName & "_" & cName
		end if
		application.lock
		application.contents.remove cName
		application.unLock
	end function

	'************************************************************
	'appCacheDeleteAll 删除全部缓存对象
	'************************************************************
	public function appCacheDeleteAll()
		dim Obj, str, data, i
		for each Obj in application.contents
			if cstr(left(Obj, len(cacheName) + 1)) = cstr(cacheName & "_") then
				str = str & Obj & ","
			end if
		next
		data = split(str, ",")
		if ubound(data) > 0 then
			for i = 0 to ubound(data) - 1
				application.lock
				application.contents.remove data(i)
				application.unLock
			next
		end if
	end function
end class
%>